package com.blue.listener;

import com.blue.constant.JwtConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.servlet.annotation.WebListener;

@Component
public class ApplicationShutdownListener implements ApplicationListener<ContextClosedEvent> {
    @Autowired
    private RedisTemplate jsonRedisTemplate;

    @Override
    public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
        System.out.println("服务器关闭了...");
        jsonRedisTemplate.delete(JwtConstant.REDIS_TOKEN_KEY);
    }
}
